﻿<%-- 
    Copyright (C) Binod Nepal, Planet Earth Solutions Pvt. Ltd., Kathmandu.
	Released under the terms of the GNU General Public License, GPL, 
	as published by the Free Software Foundation, either version 3 
	of the License, or (at your option) any later version.
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  
    See the License here <http://www.gnu.org/licenses/gpl-3.0.html>.
--%>

<%@ Page Title="My Watchlist" Language="C#" MasterPageFile="~/Classifieds/Main.Master" AutoEventWireup="true"
    CodeBehind="Watchlist.aspx.cs" Inherits="MixNP.Web.Classifieds.My.Watchlist" %>
<asp:Content ID="Content1" ContentPlaceHolderID="StyleSheetContentPlaceHolder" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ScriptsContentPlaceHolder" runat="server">
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="BodyContentPlaceHolder" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server" />
    <h1>
        My Watchlist
    </h1>
    <hr class="hr" />
    <input type="button" onclick="location.href='/dashboard.mix';" value="Dashboard" />
    <asp:UpdateProgress ID="updProgress" runat="server">
        <ProgressTemplate>
            <div class="ajax-container">
                <img alt="progress" src="/spinner.gif" class="ajax-loader" />
            </div>
        </ProgressTemplate>
    </asp:UpdateProgress>
    <asp:UpdatePanel ID="UpdatePanel1" runat="server" ChildrenAsTriggers="true" UpdateMode="Conditional">
        <Triggers>
            <asp:AsyncPostBackTrigger ControlID="WatchlistGridView" />
        </Triggers>
        <ContentTemplate>
            <div id="no-ad" class="vpad8" style="display: none;">
                You do not have any watchlist.
                <a href='/play.mix' title='Click Here to post an Ad'>
                    Click Here To Play 'Want This?'
                </a>
            </div>
            <asp:GridView ID="WatchlistGridView" runat="server" AutoGenerateColumns="False" DataKeyNames="ItemId"
                DataSourceID="SqlDataSource1" AllowPaging="True" AllowSorting="True" EmptyDataText=""
                OnRowCommand="WatchlistGridView_RowCommand" OnRowDataBound="WatchlistGridView_RowDataBound">
                <Columns>
                    <asp:TemplateField HeaderText="" ItemStyle-Width="20">
                        <ItemTemplate>
                            <asp:ImageButton ID="RemoveImageButton" runat="server" ImageUrl="~/Resources/Images/remove.png"
                                ToolTip="Remove from watchlist." CommandName="Remove" OnClientClick="return(confirm('Do you really want to remove this item from your watchlist?'));" />
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:BoundField DataField="ItemId" HeaderText="Id" ReadOnly="True" SortExpression="ItemId" />
                    <asp:BoundField DataField="Title" HeaderText="Title" SortExpression="Title" />
                    <asp:BoundField DataField="Price" HeaderText="Price" SortExpression="Price" />
                    <asp:BoundField DataField="CategoryName" HeaderText="Category" SortExpression="CategoryName" />
                    <asp:BoundField DataField="CityName" HeaderText="City" SortExpression="CityName" />
                    <asp:BoundField DataField="TotalViews" HeaderText="Hits" SortExpression="TotalViews" />
                    <asp:BoundField DataField="AddedOn" HeaderText="Added On" SortExpression="AddedOn" />
                </Columns>
            </asp:GridView>
        </ContentTemplate>
    </asp:UpdatePanel>
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:PESConnectionString %>"
        SelectCommand="SELECT * FROM [ItemView] WHERE ([EmailAddress] = @EmailAddress) AND ItemId IN(SELECT ItemId FROM WatchList WHERE ([EmailAddress] = @EmailAddress)) ORDER BY AddedOn DESC">
        <SelectParameters>
            <asp:SessionParameter Name="EmailAddress" SessionField="UserId" Type="String" />
        </SelectParameters>
    </asp:SqlDataSource>
</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="ScriptsContentPlaceHolderBottom"
    runat="server">
    <script type="text/javascript">
        jQuery(document).ready(function () {
            $(".ajax-container").height($(document).height() + 100);
        }
        );        
    </script>
</asp:Content>
